── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(FactoMineR)library(factoextra)
Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(corrplot)
corrplot 0.95 loaded
library(aricode)library(viridisLite)
Northern Range dataset
load("NORTHERN_RANGE_DATASET_COUNTS.Rdata")NR_COUNTS <- NORTHERN_RANGE_DATASET_COUNTS %>%as_tibble()NR_COUNTS <- NR_COUNTS[, -21]load("NORTHERN_RANGE_DATASET_COVARIATES.Rdata")NR_COVARIATES <- NORTHERN_RANGE_DATASET_COVARIATES %>%as_tibble() %>%rename(latitude = LATITUDE, longitude = LONGITUDE, long_lat = LONGLAT,coarse_gravel = coarse.gravel, fine_gravel = fine.gravel, leaf_litter = leaf.litter,time_step = TimeStep, year = YEAR, month = MONTH, stream = STREAM, disturbance = DISTURBANCE, # human activity / binary categorical variablealtitude = ALTITUDE, season = SEASON) %>%mutate(season =as.character(season),year =as.character(year),disturbance =ifelse(disturbance ==1, "yes", "no") ) %>%## flow is not reliable## time_step + month are redundant with season + year## site is redudant with disturbance + stream## long_lat is the 1st PCA axis of latitude + longitude dplyr::select(-long_lat, -site, -time_step, -month, -flow) %>%relocate(latitude, longitude, altitude, width, depth, volume, garbage, conductivity, O2, pH, temperature, turbidity, # site features coarse_gravel, fine_gravel, leaf_litter, cobble, sand, silt, boulders, canopy, # soil season, year, # sampling time stream, disturbance # categorical: place + human activity )# turbidity: ordinal variable indicating the level of turbidity# season:-> dry-start/dry-end, wet-start/wet-end, (january-> may: dry)quali_ind <-seq(ncol(NR_COVARIATES) -3, ncol(NR_COVARIATES))
## no effect of season and year## strong effect of stream and disturbanceNR_PCA %>%fviz_pca_biplot(habillage = quali_ind) +scale_color_viridis_d()
Warning: `gather_()` was deprecated in tidyr 1.2.0.
ℹ Please use `gather()` instead.
ℹ The deprecated feature was likely used in the factoextra package.
Please report the issue at <https://github.com/kassambara/factoextra/issues>.
Warning: The shape palette can deal with a maximum of 6 discrete values because more
than 6 becomes difficult to discriminate
ℹ you have requested 8 values. Consider specifying shapes manually if you need
that many of them.
Warning: Removed 76 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: The shape palette can deal with a maximum of 6 discrete values because more
than 6 becomes difficult to discriminate
ℹ you have requested 8 values. Consider specifying shapes manually if you need
that many of them.
Warning: Removed 76 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
pred_stream <-predict(classifier, newdata = NR_test, type ="response")aricode::ARI(pred_stream, NR_test$stream)
[1] 0.8369625
Mixture models
NR_PLNMM_all <-PLNmixture(Abundance ~1+ PC1, clusters =1:8, data = NR_DATA)
Initialization...
Adjusting 8 PLN mixture models.
number of cluster = 1
number of cluster = 2
number of cluster = 3
number of cluster = 4
number of cluster = 5
number of cluster = 6
number of cluster = 7
number of cluster = 8
Smoothing PLN mixture models.
Going backward +++++++
Going forward +++++++
Post-treatments
DONE!
Warning: The shape palette can deal with a maximum of 6 discrete values because more
than 6 becomes difficult to discriminate
ℹ you have requested 8 values. Consider specifying shapes manually if you need
that many of them.
Warning: Removed 76 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).